package com.dtranx.tools.corpora.ability.search;

import co.elastic.clients.elasticsearch._types.query_dsl.BoolQuery;
import com.dtranx.tools.corpora.ability.vo.MatchingVo;
import com.dtranx.tools.corpora.abilityapi.enums.SearchMode;
import lombok.extern.slf4j.Slf4j;

/**
 * 全词包含匹配
 * @ClassName SearchModeSearch
 * @Description TODO
 * @Date 2024/3/12 16:40
 * @Author ly
 **/
@Slf4j
public class SearchPrefixModeSearch extends AbstractModeSearch{

    @Override
    public void buildQueryBuilder0(BoolQuery.Builder queryBuilder, MatchingVo matchingVo) {
        // 前缀匹配
        queryBuilder.must(matchPhrasePrefixQuery(matchingVo, matchingVo.getValue()));
    }

    @Override
    public SearchMode getMode() {
        return SearchMode.SEARCH_PREFIX;
    }
}
